var isAnagram = function(s, t) {
    let map = new Map()
    let n = s.length,
        m = t.length;
    if(n!==m) return false
    for(var i=0;i<n;i++){
        if(map.has(s[i])){
            var count = map.get(s[i])
            map.set(s[i],++count)
        }else{
            map.set(s[i],1)
        }
    }
    console.log(map);
    for(var i=0;i<m;i++){
        if(map.has(t[i])){
            var count = map.get(t[i])
            map.set(t[i],--count)
            if(map.get(t[i])<0) return false
        }else{
            return false
        }
    }
    return true
};

//console.log(isAnagram("anagram","nagaram"));